package xyf.p11.other;

import java.util.Arrays;

/**
 * ClassName: J061_IsStraight
 * Description:
 * Author: xyf
 * Date: 9/16/22 9:46 PM
 * Version: 1.0
 **/
public class J061_IsStraight
{
    public boolean isStraight(int[] nums)
    {
        Arrays.sort(nums);
        int i = 0;
        while (i < nums.length - 1 && nums[i] == 0)
        {
            i++;
        }

        if (i == nums.length || i == nums.length - 1)
        {
            return true;
        }
        for (int j = i; j < nums.length - 1; j++)
        {
            if (nums[j + 1] == nums[j])
            {
                return false;
            }
        }

        int gap = nums[nums.length - 1] - nums[i];
        return gap < 5;
    }
}
